{extend name="public/base" /}

{block name="content-header"}
	<h5><i class="fa fa-fw fa-connectdevelop"></i> 插件列表</h5>
</block>

{block name="body"}
<div class="row">
	<div class="col-xs-12">
		<div>
			<div href="{:url('create')}" class="ajax-get iframe btn btn-sm bg-green"><i class="fa fa-fw fa-plus"></i>快速创建</div>
		</div>
		<!-- 数据列表 -->
		<div class="table-responsive margin-top-5">
			<table class="table table-bordered table-striped table-hover">
				<thead>
					<tr>
						<th>名称</th>
						<th>标识</th>
						<th>描述</th>
						<th>钩子</th>
						<th>状态</th>
						<th>作者</th>
						<th>版本</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{notempty name="_list"}
					{volist name="_list" id="vo"}
					<tr>
						<td>{$vo.title}</td>
						<td>{$vo.name}</td>
						<td>{$vo.description}</td>
						<?php $addons_hook = addons_hook($vo['name']); ?>
						<td><a href="{:url('addons/edithook',['id'=>$addons_hook.id])}">{$addons_hook['name']}</a></td>
						<td>{$vo.status_text|default="未安装"}</td>
						<td class="text-success"><a target="_blank" href="{$vo.url|default='http://www.twothink.cn'}">{$vo.author}</a></td>
						<td>{$vo.version}</td>
						<td>
							{empty name="vo.uninstall"}
								<?php
									$class	= get_addon_class($vo['name']);
									if(!class_exists($class)){
										$has_config = 0;
									}else{
										$addon = new $class();
										$has_config = count($addon->getConfig());
									}
								?>
								<?php if ($has_config): ?>
									<a href="{:url('config',array('id'=>$vo['id']))}" class="ajax-get iframe  btn btn-xs btn-default" title="设置"><i class="fa fa-fw fa-cog"></i></a>
								<?php endif; ?>
							<?php if ($vo['status'] >=0): ?>
								{eq name="vo.status" value="0"}
									<a class="ajax-get btn btn-xs bg-green" href="{:url('enable',array('id'=>$vo['id']))}" title="启用"><i class="fa fa-fw fa-unlock"></i> </a>
								{else /}
									<a class="ajax-get btn btn-xs bg-yellow" href="{:url('disable',array('id'=>$vo['id']))}" title="禁用"><i class="fa fa-fw fa-lock"></i> </a>
								{/eq}
							<?php endif ?>
								{// <eq name="vo.author" value="thinkphp">}
									<a class="ajax-get btn btn-xs btn-danger" href="{:url('uninstall?id='.$vo['id'])}" title="卸载"><i class="fa fa-fw fa-trash-o"></i> </a>
								{// </eq>}
							{else /}
								<a class="ajax-get btn btn-xs bg-gray-active" href="{:url('install?addon_name='.$vo['name'])}" title="安装"><i class="fa fa-fw fa-shekel"></i> </a>
							{/empty}
						</td>
					</tr>
					{/volist}
					{else/}
					<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
					{/notempty}
				</tbody>
			</table>
		</div>
		<!-- 分页 -->
		<div class="page">
			{$_page}
		</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function(){
        highlight_subnav('{:url("addons/index")}');
    })
</script>
{/block}
